﻿
using System.Collections.Generic;
using Test30.Core;
using Test30.Util;

namespace Test30.Engine
{
    public class ItemDrop : IDrop<Item>
    {
        public ItemDrop(NotNull<ItemType> itemType, Roller quantity)
        {
            _itemType = itemType;
            _quantity = quantity;
        }

        public ItemDrop(NotNull<ItemType> itemType)
            : this(itemType, null)
        {
        }

        public IEnumerable<Item> Create(int level)
        {
            Item item = Item.Random(Vec.Zero, _itemType, level);

            if (_quantity != null)
            {
                // override the quantity
                item.Quantity = _quantity.Roll();
            }

            yield return item;
        }

        private readonly ItemType _itemType;
        private readonly Roller _quantity;
    }

}
